/*
 *
 * Copyright (c) 2021
 * User:Dybala
 * File:redisService.java
 * Date:2021/11/08 11:11:08
 */

package com.service;

import com.dao.RedisDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Service
public class redisService {
    @Autowired
    RedisDao dao;
    /**
     * 获取redis中的值
     * @param key 作为参数的key
     * @return
     */
    public String get(String key) {
        return dao.get(key);
    }

    /**
     * 更新redis
     * @param token
     */
    public void reNew(String token){

    }

    /**
     * set redis
     * @param key key：前缀+token
     * @param value value：token
     */
    public void set(String key,String value){
        dao.set(key, value);
    }

    /**
     * 设置过期时间
     * @param key key
     * @param time 过期时间
     */
    public void expire(String key,long time){
        dao.expire(key, time);
    }

    /**
     * 删除redis中的key
     * @param key 待删除的key
     */
    public void del(String key) {
        dao.del(key);
    }
}
